package com.jar.exercise.java8新特性.日期API;

import org.junit.Test;

import java.time.Duration;
import java.time.LocalTime;

/**
 * @author ZhangShengHao
 * @className Demo1
 * @description TODO
 * @date 2020/1/28 18:02
 */
public class Demo {
	@Test
	public void testDuration() {
		LocalTime localTime = LocalTime.now();
		LocalTime localTime2 = LocalTime.of(19, 19, 19);
		Duration duration = Duration.between(localTime, localTime2);
		System.out.println(duration);
		System.out.println(duration.isZero());            //Duration区间是否为0
		System.out.println(duration.isNegative());        //Duration区间是否为负

		System.out.println(duration.getSeconds());        //Duration区间值的秒数
		System.out.println(duration.getNano());            //Duration区间值的纳秒数
		System.out.println(duration.getUnits());        //Duration的度量单位

		System.out.println(duration.toDays());            //Duration区间相差几天
		System.out.println(duration.toHours());            //Duration区间差几小时
		System.out.println(duration.toMinutes());        //Duration区间相差几分钟
		System.out.println(duration.toMillis());        //Duration区间相差几毫秒

		//============ duration 时间区间的加减 省略  ============
	}
}
